package com.party.course.controller;


import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.party.common.annotation.Log;
import com.party.common.core.controller.BaseController;
import com.party.common.core.domain.AjaxResult;
import com.party.common.enums.BusinessType;
import com.party.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.party.course.domain.AgreementInfo;
import com.party.course.service.IAgreementInfoService;
import com.party.common.core.page.TableDataInfo;

/**
 * 教练端协议设置Controller
 *
 * @author ruoyi
 * @date 2025-06-04
 */
@RestController
@RequestMapping("/course/agreementInfo" )
public class AgreementInfoController extends BaseController {
    @Autowired
    private IAgreementInfoService agreementInfoService;

/**
 * 查询教练端协议设置列表
 */
//@RequiresPermissions("course:agreementInfo:list")
@GetMapping("/list" )
    public TableDataInfo list(AgreementInfo agreementInfo) {
        startPage();
        List<AgreementInfo> list = agreementInfoService.findList(agreementInfo);
        return getDataTable(list);
    }

    /**
     * 导出教练端协议设置列表
     */
    //@RequiresPermissions("course:agreementInfo:export")
    @Log(title = "教练端协议设置" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, AgreementInfo agreementInfo) {
        List<AgreementInfo> list = agreementInfoService.findList(agreementInfo);
        ExcelUtil<AgreementInfo> util = new ExcelUtil<AgreementInfo>(AgreementInfo. class);
        util.exportExcel(response, list, "教练端协议设置数据" );
    }

    /**
     * 获取教练端协议设置详细信息
     */
    //@RequiresPermissions("course:agreementInfo:query")
    @GetMapping(value = "/view/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) String id) {
        return AjaxResult.success(agreementInfoService.view(id));
    }

    @GetMapping(value = "/findOne" )
    public AjaxResult findOne() {
        return AjaxResult.success(agreementInfoService.findOne());
    }

    /**
     * 新增教练端协议设置
     */
    //@RequiresPermissions("course:agreementInfo:add")
    @Log(title = "教练端协议设置" , businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody AgreementInfo agreementInfo) {
        return toAjax(agreementInfoService.add(agreementInfo));
    }

    /**
     * 修改教练端协议设置
     */
    //@RequiresPermissions("course:agreementInfo:edit")
    @Log(title = "教练端协议设置" , businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public AjaxResult edit(@RequestBody AgreementInfo agreementInfo) {
        return toAjax(agreementInfoService.updateEntity(agreementInfo));
    }

    /**
     * 删除教练端协议设置
     */
    //@RequiresPermissions("course:agreementInfo:remove")
    @Log(title = "教练端协议设置" , businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/{ids}" )
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(agreementInfoService.deleteIds(Arrays.asList(ids)));
    }
}
